<template>
    <div>
        <h1>门店添加</h1>
        <table>
            <tr>
                <td>名称</td>
                <td>
                    <input type="text"  v-model="state.mname"/>  
                </td>
            </tr>
            <tr>
                <td>电话</td>
                <td>
                    <input type="text" v-model="state.mphone" />
                </td>
            </tr>
            <tr>
                <td>简介</td>
                <td>
                    <input type="text" v-model="state.mjianjie" />
                </td>
            </tr>
            <tr>
                <td>地址</td>
                <td>
                    <input type="text" v-model="state.dizhi" />
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" value="添加" @click="tianjia"/>
                </td>
                <td></td>
            </tr>

        </table>
    </div>
</template>

<script setup lang="ts">
import {  reactive,toRefs, onMounted} from 'vue'
import { useRoute,useRouter } from 'vue-router'
import axios from 'axios'   
const router = useRouter()
const route = useRoute()

const data=reactive({
    state:{
        mname:'',
        mphone:'',
        mjianjie:'',
        dizhi:''

    }
})

const {state}=toRefs(data)

const tianjia=()=>{
    axios({
        url:'https://localhost:7271/api/Member/AddMember',
        method:'post',
        data:data.state
    }).then((res)=>{
        if(res.data.data>0){
           alert('添加成功')
           router.push('/MembershowView')
           
           return;
           
           
        }else{
            alert('添加失败')
            return;
        }
    })
    .catch((err)=>{
        console.log(err)
    })
}

</script>

<style scoped>

</style>